package com.example.forjava.model.chain;

import java.util.Objects;

public abstract class ProcessingObject<T> {
    protected ProcessingObject<T> processingObject;

    public void setHandler(ProcessingObject<T> processingObject) {
        this.processingObject = processingObject;
    }

    public void handle(T input) {
        handleRequest(input);
        if (Objects.nonNull(processingObject)) {
             processingObject.handle(input);
        }
    }

    public abstract void handleRequest(T input);
}